package com.jerei.crm.util;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 用于封装向客户端响应的结果的类
 * @param <T> 向客户端响应的数据的类型  JsonResult<任意类型>
 */
public class JsonResult<T> {
    private Integer state;//状态信息
    private String message;//错误信息
    @JsonInclude(JsonInclude.Include.ALWAYS)
    private T data;//响应数据

    public JsonResult() {
    }

    public JsonResult(Integer state) {
        this.state = state;
    }

    public JsonResult(String message) {
        this.message = message;
    }

    public JsonResult(Throwable ex){
        this.message=ex.getMessage();
    }

    public JsonResult(Integer state, T data) {
        this.state = state;
        this.data = data;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
